import {baseEffects, baseReducers, baseState} from "../../../../models/baseModel";
import PageHelper from "utils/pageHelper";
import moment from "moment";
import * as request from "../../../../services/CommonHttpService";
import AppService from "../../../../common/AppService";

export default {
  namespace: 'pushDetails',

  state: {
    ...baseState,
  },

  reducers: {
    ...baseReducers
  },

  effects: {

    ...baseEffects,

    // 进入页面加载
    * init({payload}, {put, call}) {
      const p = {
        ...payload,
        baseUrl: getBaseUrl(),
        server: AppService.dataUrl,
        process: (records) => {
          return records.map(data => {
            return {
              ...data,
              pushTime: moment(data.pushTime).format('YYYY-MM-DD HH:mm:ss')
            };
          });
        }
      };
      yield put({
        type: 'baseGetPageInfo',
        payload: p
      });
    },
  }

}

function getBaseUrl() {
  return "/push/record/detail";
}
